import axios from "axios"
import nProgress from "nprogress";
import 'nprogress/nprogress.css'
const request = axios.create({
    baseURL:'/mock',
    timeout:20000
});//创建出一个axios实例

//请求拦截
request.interceptors.request.use((config)=>{
    nProgress.start();
    return config
},(err)=>{
    nProgress.done();
    return Promise.reject(err)
})

//响应拦截
request.interceptors.response.use((response)=>{
    nProgress.done();
    return response.data;
},(err)=>{
    console.log(err);
    nProgress.done();
    return Promise.reject(err)
})
export default request;